package com.nuoniu.sibanyun.controller.expenses;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.expenses.dto.ChangeRenewalTypeDto;
import com.nuoniu.sibanyun.entity.expenses.dto.ExpensesPropertySearchDto;
import com.nuoniu.sibanyun.entity.expenses.dto.RenewalDto;
import com.nuoniu.sibanyun.service.expenses.IExpensesPropertyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 费用中心-续费管理 前端控制器
 * </p>
 *
 * @author 白强
 * @since 2022-05-09
 */
@RestController
@RequestMapping("/expenses/property")
@Api(value="费用中心-续费管理 ",tags={"费用中心-续费管理"})
public class ExpensesPropertyController extends BaseController {

    @Autowired
    private IExpensesPropertyService propertyService;

    @PostMapping("pageList")
    @ApiOperation(value = "分页查询 续费（资源）管理")
    public HttpResult pageList(@RequestBody ExpensesPropertySearchDto propertySearchDto) {
        return HttpResult.ok(propertyService.pageList(propertySearchDto));
    }

    @PostMapping("batchRenewalByCompany")
    @ApiOperation(value = "批量续费(租户)")
    public HttpResult batchRenewalByCompany(@RequestBody List<RenewalDto> renewalDtos) {
        propertyService.batchRenewalByCompany(renewalDtos);
        return HttpResult.ok();
    }

    @PostMapping("changeRenewalType")
    @ApiOperation(value = "更改续费方式")
    public HttpResult changeRenewalType(@RequestBody ChangeRenewalTypeDto changeRenewalTypeDto) {
        propertyService.changeRenewalType(changeRenewalTypeDto);
        return HttpResult.ok();
    }

}
